<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <div id="div">我是div</div>


        <script type="text/javascript">

            //获取div标签元素
            var divObj = document.getElementById("div");

            //需求1：获取标签体的内容
            var innerHTML = divObj.innerHTML; //获取标签内的文本内容及子标签内容
            console.log("html = " + innerHTML)

            var innerText = divObj.innerText; //仅获取标签内的文本内容
            console.log("text = " + innerText)


            //修改div标签中的文本内容
            //divObj.innerText="测试的内容"
            divObj.innerHTML="<span style='color: red'>我是div</span>"

        </script>

    </body>
</html>